/**********************************************************************************************************************/
* 
*   "Civil War and Citizens' Demand for the State: An Empirical Test of Hobbesian Theory"
*	Replication Files
*   Robert A. Blair
*
***********************************************************************************************************************/



					clear
					set more off, permanently



					gl replication "[YOUR DIRECTORY HERE]"		




*********
* SETUP *
*********

					use "$replication/data/residents_data.dta", clear
	
					svyset [pweight=pweight], psu(commcode) strata(county)			
									
					gl I_TRIBES r2_c_bassa-r2_c_other
					
					gl I_CONTROLS r2_c_age_imputed r2_c_male r2_c_born_town r2_c_past_lead r2_c_past_leadrel r2_c_prewar_unemployed r2_c_prewar_land_any $I_TRIBES 

					gl C_CONTROLS ofhouses school_yes health_yes wdaccessinwet_yes
																											
					gl DISTRICTS district_fe*
					
					gl COMMUNITIES community_fe*


	




						
************
* ANALYSIS *
************


						
	*** Table 1
						
					local title "table1"

					cap erase "$replication/output/`title'.xls"
					cap erase "$replication/output/`title'.txt"

					foreach y in r2_c_state_top r2_c_local_top r2_c_unmil_top {
						local lab : var label `y'
							svy: reg `y' r2_c_viol_experienced_std $I_CONTROLS $COMMUNITIES
								outreg2 using "$replication/output/`title'.xls", ///
									append excel lab ctitle(`lab') aster(se) dec(3) br nocons keep(r2_c_viol_experienced_std)
								}
							
					foreach y of varlist r2_c_state_top r2_c_local_top r2_c_unmil_top {
						local lab : var label `y'
						svy: reg `y' r2_c_viol_direct_std r2_c_viol_fam_std $I_CONTROLS $COMMUNITIES
						outreg2 using "$replication/output/`title'.xls", ///
							append excel lab ctitle(`lab') aster(se) dec(3) br nocons keep(r2_c_viol_direct_std r2_c_viol_fam_std)
						}
							

							
	*** Table 2
						
					local title "table2"
						
					cap erase "$replication/output/`title'.xls"
					cap erase "$replication/output/`title'.txt"
						
					foreach y in r2_c_state_top r2_c_local_top r2_c_unmil_top {
						foreach x in acled_num_wartime acled_any_wartime acled_any_wartime_d_i10 {
							local lab : var label `y'
								svy: reg `y' `x' $I_CONTROLS $DISTRICTS
									outreg2 using "$replication/output/`title'.xls", ///
										append excel lab ctitle(`lab') aster(se) dec(3) br nocons keep(`x')
								}
							}
									
			
						
						
	*** Table 3
						
					local title "table3"
					
					cap erase "$replication/output/`title'.xls"
					cap erase "$replication/output/`title'.txt"

					foreach y in r2_c_anyreport r2_c_anyreport_alt {
						local lab : var label `y'
							svy: reg `y' r2_c_viol_experienced_std $I_CONTROLS $COMMUNITIES
								outreg2 using "$replication/output/`title'.xls", ///
									append excel lab ctitle(`lab') aster(se) dec(3) br nocons keep(r2_c_viol_experienced_std)
							}
							
					foreach y of varlist r2_c_anyreport r2_c_anyreport_alt {
						local lab : var label `y'
						svy: reg `y' r2_c_viol_direct_std r2_c_viol_fam_std $I_CONTROLS $COMMUNITIES
						outreg2 using "$replication/output/`title'.xls", ///
							append excel lab ctitle(`lab') aster(se) dec(3) br nocons keep(r2_c_viol_direct_std r2_c_viol_fam_std)
						}

					
										
						

	*** Table 4
											
					local title "table4"
						
					cap erase "$replication/output/`title'.xls"
					cap erase "$replication/output/`title'.txt"
						
					foreach y in r2_c_anyreport r2_c_anyreport_alt {
						foreach x in acled_num_wartime acled_any_wartime acled_any_wartime_d_i10 {
							local lab : var label `y'
								svy: reg `y' `x' $I_CONTROLS $DISTRICTS
									outreg2 using "$replication/output/`title'.xls", ///
										append excel lab ctitle(`lab') aster(se) dec(3) br nocons keep(`x')
								}
							}


					
	*** Table 6

					local title "table6"
										
					cap erase "$replication/output/`title'.xls"
					cap erase "$replication/output/`title'.txt"

					local lab : var label r2_c_igenheavy
						svy: reg r2_c_igenheavy r2_c_viol_experienced_std $I_CONTROLS $COMMUNITIES
							outreg2 using "$replication/output/`title'.xls", ///
								append excel lab ctitle(`lab') aster(se) dec(3) br nocons keep(r2_c_viol_experienced_std)

					local lab : var label r2_c_igenheavy
						svy: reg r2_c_igenheavy r2_c_viol_direct_std r2_c_viol_fam_std $I_CONTROLS $COMMUNITIES
							outreg2 using "$replication/output/`title'.xls", ///
								append excel lab ctitle(`lab') aster(se) dec(3) br nocons keep(r2_c_viol_direct_std r2_c_viol_fam_std)

					


	*** Table7
						
					local title "table7"
						
					cap erase "$replication/output/`title'.xls"
					cap erase "$replication/output/`title'.txt"
											
					foreach x in acled_num_wartime acled_any_wartime acled_any_wartime_d_i10 {
						local lab : var label r2_c_igenheavy
							svy: reg r2_c_igenheavy `x' $I_CONTROLS $DISTRICTS
								outreg2 using "$replication/output/`title'.xls", ///
									append excel lab ctitle(`lab') aster(se) dec(3) br nocons keep(`x')
							}

	
	

			
					
					
	
	
